<template>
		<view class="content">
			<view class="content-block">
				<text class="content-sub">{{dataIndex+1}}、{{getSubjectDesc}}（ ）</text>
			</view>
			<view v-if="judgeChoiceType == 1">
				<view :class="[item.showClass]" v-for="item in newSubjectChoices" :key="item.choiceId" 
				@click="radioChange(item.choiceId)">
					<text>{{item.choiceId}}、</text>
					<text class="content-opt">{{item.choiceDesc}}</text>
				</view>
			</view>

			<view v-if="judgeChoiceType == 2">
				<view :class="[item.showClass]" v-for="item in newSubjectChoices" :key="item.choiceId" 
				@click="checkChange(item.choiceId)">
					<text>{{item.choiceId}}、</text>
					<text class="contentd-opt">{{item.choiceDesc}}</text>
				</view>
			</view>
		</view>
</template>

<script>
	export default {
		data(){
			return{
				
			}
		},
		props: {
			subject: undefined,
			dataIndex: {
				type: Number,
				default: 0
			},
			subjectSize: undefined
		},
		computed: {
			
			judgeChoiceType() { //页面展示单选还是多选 1 单选 2 多选
				if (this.subject != "") {
				    return this.subject.choiceType == 1 ? 1:2
				}
			},
			getSubjectDesc() { //题目
				return this.subject != "" ? this.subject.subjectDesc : ""
			},
			getSubjectChoices() { //获取答案选项
                return this.subject != "" ? this.subject.subjectChoices : ""
			},
            answer() {
                return this.subject != "" ? this.subject.answer : ""
            },
            selectChoice() { //学生答案
                return this.subject != "" ? this.subject.selectChoice : ""
            },
			newSubjectChoices() {
			    let _this = this
				if(_this.subject.showAnalysis==1){
					if (_this.getSubjectChoices != "") {
                        _this.getSubjectChoices.forEach(
							item => {
								//答案选项
								if(_this.answer!=undefined && _this.answer.find(v => item.choiceId == v) != undefined){
									item.showClass = 'content-ana-itemc'
								}else{
									//非答案，用户没选
									if(_this.selectChoice!=undefined && _this.selectChoice.find(v => item.choiceId == v) == undefined){
										item.showClass = 'content-ana-item'
									}else{//非答案，用户选了
										item.showClass = 'content-ana-iteme'
									}
								}
							}
						)
						console.log(_this.getSubjectChoices)
						return _this.getSubjectChoices;
					} else {
						return false
					}
				}else{
					if (_this.getSubjectChoices != false) {
                        _this.getSubjectChoices.forEach(
							item => {
								if (item.isChose == 0) { //未选
									item.showClass = 'content-item'
								} else { //已选 == 1
									item.showClass = 'content-itemc'
								}
							})
						return _this.getSubjectChoices;
					} else {
						return ""
					}
				}
			}
		},
		methods: {
			checkChange(choiceId){
				this.$emit("checkChange",choiceId)
			},
			radioChange(choiceId){
				this.$emit("radioChange",choiceId)
			}
		}
	}
</script>

<style lang="scss" scoped>
	
	.content {
		margin: 20upx;
		font-size: 30upx;
		border-radius: 8rpx;
		box-shadow: 0 0 10upx #eaeaea;
		padding: 30upx 30upx;

		&-block {
			margin-bottom: 40upx;
		}

		&-sub {
			color: #000;
			font-weight: bold;
		}

		&-item {
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			align-items: flex-start;
			margin: 20upx 0;
			padding: 30upx 20upx;
			font-size: 26upx;
			width: 630upx;
			background: #f4f6f8;
			border-radius: 8rpx;
			color: #000;
		}

		&-itemc {
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			align-items: flex-start;
			margin: 20upx 0;
			padding: 30upx 20upx;
			font-size: 26upx;
			width: 630upx;
			background: #5ea1f8;
			color: #fff;
			border-radius: 8rpx;
		}
		&-ana-item {
			margin: 20upx 0;
			padding: 0 20upx;
			width: 630upx;
			height: 80upx;
			background: #f4f6f8;
			border-radius: 8rpx;
			color: #666;
		}
		
		&-ana-itemc {
			margin: 20upx 0;
			padding: 0 20upx;
			width: 630upx;
			height: 80upx;
			background: #5ea1f8;
			color: #fff;
			border-radius: 8rpx;
			color: #fff;
		}
		
		&-ana-iteme {
			margin: 20upx 0;
			padding: 0 20upx;
			width: 630upx;
			height: 80upx;
			background: #f1685d;
			color: #fff;
			border-radius: 8rpx;
			color: #fff;
		}
		

		&-ico {
			display: inline-block;
			width: 40upx;
			height: 40upx;
			border: 1px solid #377cfd;
			border-radius: 50%;
			margin-right: 30upx;
			color: #377cfd;
			text-align: center;
			color: #377cfd;
			line-height: 80upx;
		}

		&-icoc {
			display: inline-block;
			width: 40upx;
			height: 40upx;
			border: 1px solid #377cfd;
			border-radius: 50%;
			margin-right: 30upx;
			text-align: center;
			color: #fff;
			background: #377cfd;
			line-height: 80upx;
		}

		&-opt {
			display: inline-block;
			/*line-height: 80upx;*/
			line-height: 1.5;
		}

	}

	.contentd {
		margin: 40upx;
		font-size: 30upx;

		&-block {
			margin-bottom: 40upx;
		}

		&-type {
			color: #377cfd;
			font-weight: bold;
		}

		&-sub {
			color: #000;
			font-weight: bold;
		}

		&-item {
			margin: 20upx 0;
			font-size: 26upx;
		}

		&-ico {
			display: inline-block;
			width: 40upx;
			height: 40upx;
			border: 1px solid #377cfd;
			border-radius: 50%;
			margin-right: 30upx;
			color: #377cfd;
			text-align: center;
			color: #377cfd;
		}

		&-icoc {
			display: inline-block;
			width: 40upx;
			height: 40upx;
			border: 1px solid #377cfd;
			border-radius: 50%;
			margin-right: 30upx;
			text-align: center;
			color: #fff;
			background: #377cfd;
		}

		&-opt {
			display: inline-block;
			/*line-height: 80upx;*/
			line-height: 1.5;
		}

	}

	
</style>
